package com.suixinsanren.design.responsibilitychain.demo02;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

public class StudentNoCheck extends AbsCheckStudent {

    private final int STUDENT_NO_MAX_LEN = 1;
    private final String NONE_STR = "";

    @Override
    public List<Student> checkStudentInfo(List<Student> studentList) {
        List<Student> checkFailedStudents = studentList.stream().filter(student -> Objects.isNull(student.getStNo()) || student.getStNo().length() < STUDENT_NO_MAX_LEN || NONE_STR.equals(student.getStNo())).collect(Collectors.toList());
        System.out.println("学号检查失败的学生 = " + checkFailedStudents);
        studentList.removeAll(checkFailedStudents);
        System.out.println("学号检查通过的学生 = " + studentList);
        return studentList;
    }
}
